package com.googlecode.jerato.common.view;

import java.util.List;

import com.googlecode.jerato.common.data.ColumnListSelect;
import com.googlecode.jerato.core.view.ViewParameters;
import com.googlecode.jerato.core.view.ViewTransfer;
import com.googlecode.jerato.library.SystemService;
import com.googlecode.jerato.library.store.StoreService;
import com.googlecode.jerato.library.view.ViewParametersImpl;
import com.googlecode.jerato.library.view.ViewService;
import com.googlecode.jerato.library.view.ViewTransferImpl;
import com.googlecode.jerato.library.view.xml.XmlView;

public class TableDataView extends XmlView{
	public void prepare(ViewTransfer trans, ViewParameters input, ViewParameters output){
		String table_name = input.getString("table_name");
		List list = StoreService.getInstance().select(trans, ColumnListSelect.class, input);
		output.put("table_name", table_name);
		
		output.setObject("columnList", list);
	}

	public static void main(String[] args) {
		SystemService.staticInitialize();
		try{
			ViewParametersImpl input = new ViewParametersImpl();
			ViewParametersImpl output = new ViewParametersImpl();
			ViewTransferImpl trans = new ViewTransferImpl();
			ViewService.getInstance().render("/common/TableData.jsp", trans, input, output);
			System.out.println("----------------------------------------");
			System.out.println(trans.getStringBuffer());
			System.out.println("----------------------------------------");
		}
		finally{
			SystemService.staticFinalize();
		}
	}
}
